package com.jn.util.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import com.jn.util.CodeUtil;

public class DictCodeValueTag extends BodyTagSupport {

	private static final long serialVersionUID = -4450256677611743965L;
	private String codeType;
	private String codeName;

	@Override
	public int doStartTag() throws JspException {
		if (codeType == null)
			throw new JspException("codeType不能为空");
		if (codeName == null)
			return SKIP_BODY;
		String name = CodeUtil.getValue(codeType, codeName);
		if (name == null)
			name = "";
		try {
			this.pageContext.getOut().print(name);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return SKIP_BODY;
	}

	@Override
	public void release() {
		super.release();
		this.codeType = null;
		this.codeName = null;
	}

	public String getCodeType() {
		return codeType;
	}

	public void setCodeType(String codeType) {
		this.codeType = codeType;
	}

	public String getCodeName() {
		return codeName;
	}

	public void setCodeName(String codeName) {
		this.codeName = codeName;
	}
}
